package claybird.dom;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.OneToMany;

/*
 * Represent one competition (one day)
 */
@Entity
public class ShootDay  extends BaseEntity {
	private String name;
	private String location;
	private Date date;
	private Byte numberOfClay;
    @OneToMany(mappedBy="shootDay")
	private List<Team>listOfTeam;
    public ShootDay(){
    	
    }
    
    public ShootDay(String name, String location, Date date, Byte numberOfClay){
    	this.name = name;
    	this.location= location;
    	this.date = date;
    	this.numberOfClay= numberOfClay;
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}
	public String getStringDate(){

	      SimpleDateFormat ft = 
	      new SimpleDateFormat ("dd.MM.yyyy");
	      return ft.format(this.date);
	}
	public Date getDate() {
		return date;
	}
	@SuppressWarnings("deprecation")
	public int getYear() {
		
		return this.date.getYear()+1900;
	}
	public void setDate(Date date) {
		this.date = date;
	}

	public Byte getNumberOfClay() {
		return numberOfClay;
	}

	public void setNumberOfClay(Byte numberOfClay) {
		this.numberOfClay = numberOfClay;
	}

	public List<Team> getListOfTeam() {
		return listOfTeam;
	}

	public void setListOfTeam(List<Team> listOfTeam) {
		this.listOfTeam = listOfTeam;
	}

	public List<Person> getAllPlayers() {
		List<Person> listPerson = new ArrayList<Person>();
		for (Team tm:this.listOfTeam){
			listPerson.addAll(tm.getListPerson());
		}
		return listPerson;
	}

	
}
